package com.ay.weixin.fdc.boss.share.db;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lizar.db.ibatis.Dao;

import org.lizar.config.keys.Keys;

import com.ay.weixin.fdc.boss.share.domain.ShareBackHits;
import com.ay.weixin.fdc.boss.share.domain.ShareBackHitsDetail;

public class ShareBackHitsDao extends Dao {
	
	public void append_hits(Map params) throws SQLException{
		
		this.sqlMapper.update("share_backhits.append_hits",params);
	}
	
	public void deleteBySaId(long sa_id) throws SQLException{
		this.sqlMapper.delete("share_backhits.deleteBySaId",sa_id);
	}
	
	public List<ShareBackHitsDetail> getMyShareHitsDetail(long user_id) throws SQLException{
		return (List<ShareBackHitsDetail>)this.sqlMapper.queryForList("share_backhits.getMyShareHitsDetail",user_id);
	}
	
	public void insert(ShareBackHits backhits) throws SQLException{
		this.sqlMapper.insert("share_backhits.insert",backhits);
	}
	
	public void inc_backhits(long user_id,long sa_id,int back_hits) throws SQLException{
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("user_id",user_id);
		map.put("sa_id", sa_id);
		map.put("back_hits", back_hits);
		this.sqlMapper.update("share_backhits.inc_backhits",map);
	}
	
	public ShareBackHits getByIds(long user_id,long sa_id) throws SQLException{
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("user_id",user_id);
		map.put("sa_id", sa_id);
		return (ShareBackHits)this.sqlMapper.queryForObject("share_backhits.getByIds",map);
	}
	
	public void update_reward(long id,String reward) throws SQLException{
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("id",id);
		map.put("reward", reward);
		this.sqlMapper.update("share_backhits.update_reward",map);
	}
	
	public List<ShareBackHits> getBackHitsTopList(long sa_id,int size) throws SQLException{
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("sa_id",sa_id);
		map.put("size", size);
		map.put("user_table", Keys.getStr("usercenter.user_table_name"));
		return (List<ShareBackHits>)this.sqlMapper.queryForList("share_backhits.getBackHitsTopList",map);
	}
	
}
